//
//  Array+Extension.swift
//  SwiftDemo
//
//  Created by 宏泰财富 on 2018/11/8.
//  Copyright © 2018 宏泰财富. All rights reserved.
//

import Foundation

extension Array {
    
    func accumulate<Result>(_ initalResult: Result, _ nextPartiaResult:(Result, Element)->Result) -> [Result] {
        var running = initalResult
        return map{ next in
            running = nextPartiaResult(running, next)
            return running
        }
    }
 
}
